<?php
class ActivityPersonalGoalsInfoVo extends SzAbstractMySqlVo
{

    private $userId;
    private $indexId;
    private $info;
    private $exchangeInfo;
    private $totalNum;
    private $useNum;
    private $noUsedWater;
    private $noUsedFlowerBasket;
    private $giftPackRefreshTime;

    /**
     * Initialize ActivityPersonalGoalsInfoVo.
     *
     * @param $userId
     * @param $indexId
     * @param $info
     * @param $exchangeInfo
     * @param $totalNum
     * @param $useNum
     * @param $noUsedWater
     * @param $noUsedFlowerBasket
     * @param $giftPackRefreshTime
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return ActivityPersonalGoalsInfoVo
     */
    public function __construct($userId, $indexId, $info, $exchangeInfo, $totalNum, $useNum, $noUsedWater, $noUsedFlowerBasket, $giftPackRefreshTime, $isInsert = false) {
        $this->userId = $userId;
        $this->indexId = $indexId;
        $this->info = json_decode($info, true);
        $this->exchangeInfo = json_decode($exchangeInfo, true);
        $this->totalNum = $totalNum;
        $this->useNum = $useNum;
        $this->noUsedWater = $noUsedWater;
        $this->noUsedFlowerBasket = $noUsedFlowerBasket;
        $this->giftPackRefreshTime = $giftPackRefreshTime;

        $this->isInsert = $isInsert;
        $this->voClassName = 'ActivityPersonalGoalsInfoVo';
        $this->ormName = 'ActivityPersonalGoalsInfo';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'indexId' => $this->getIndexId(),
            'info' => ($needEncode) ? $this->getInfo() : $this->getRawInfo(),
            'exchangeInfo' => ($needEncode) ? $this->getExchangeInfo() : $this->getRawExchangeInfo(),
            'totalNum' => $this->getTotalNum(),
            'useNum' => $this->getUseNum(),
            'noUsedWater' => $this->getNoUsedWater(),
            'noUsedFlowerBasket' => $this->getNoUsedFlowerBasket(),
            'giftPackRefreshTime' => $this->getGiftPackRefreshTime(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'indexId' => $this->getIndexId(),
            'info' => ($needEncode) ? $this->getInfo() : $this->getRawInfo(),
            'exchangeInfo' => ($needEncode) ? $this->getExchangeInfo() : $this->getRawExchangeInfo(),
            'totalNum' => $this->getTotalNum(),
            'useNum' => $this->getUseNum(),
            'noUsedWater' => $this->getNoUsedWater(),
            'noUsedFlowerBasket' => $this->getNoUsedFlowerBasket(),
            'giftPackRefreshTime' => $this->getGiftPackRefreshTime(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getIndexId(),
            $this->getInfo(),
            $this->getExchangeInfo(),
            $this->getTotalNum(),
            $this->getUseNum(),
            $this->getNoUsedWater(),
            $this->getNoUsedFlowerBasket(),
            $this->getGiftPackRefreshTime(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getIndexId()
    {
        return $this->indexId;
    }

    public function setIndexId($val)
    {
        $this->saveColumnStatus(1, $this->indexId);
        $this->indexId = $val;
    }

    public function getInfo()
    {
        return json_encode($this->info);
    }

    public function getRawInfo()
    {
        return $this->info;
    }

    public function setInfo($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[ActivityPersonalGoalsInfoVo] The length of column info exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('ActivityPersonalGoalsInfoVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[ActivityPersonalGoalsInfoVo] The length of column info exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(2, $this->info);
        $this->info = $val;
    }

    public function getExchangeInfo()
    {
        return json_encode($this->exchangeInfo);
    }

    public function getRawExchangeInfo()
    {
        return $this->exchangeInfo;
    }

    public function setExchangeInfo($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[ActivityPersonalGoalsInfoVo] The length of column exchangeInfo exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('ActivityPersonalGoalsInfoVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[ActivityPersonalGoalsInfoVo] The length of column exchangeInfo exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(3, $this->exchangeInfo);
        $this->exchangeInfo = $val;
    }

    public function getTotalNum()
    {
        return $this->totalNum;
    }

    public function setTotalNum($val)
    {
        $this->saveColumnStatus(4, $this->totalNum);
        $this->totalNum = $val;
    }

    public function getUseNum()
    {
        return $this->useNum;
    }

    public function setUseNum($val)
    {
        $this->saveColumnStatus(5, $this->useNum);
        $this->useNum = $val;
    }

    public function getNoUsedWater()
    {
        return $this->noUsedWater;
    }

    public function setNoUsedWater($val)
    {
        $this->saveColumnStatus(6, $this->noUsedWater);
        $this->noUsedWater = $val;
    }

    public function getNoUsedFlowerBasket()
    {
        return $this->noUsedFlowerBasket;
    }

    public function setNoUsedFlowerBasket($val)
    {
        $this->saveColumnStatus(7, $this->noUsedFlowerBasket);
        $this->noUsedFlowerBasket = $val;
    }

    public function getGiftPackRefreshTime()
    {
        return $this->giftPackRefreshTime;
    }

    public function setGiftPackRefreshTime($val)
    {
        $this->saveColumnStatus(8, $this->giftPackRefreshTime);
        $this->giftPackRefreshTime = $val;
    }

    public function updateTotalNum($val)
    {
        $this->saveColumnStatus(4, $this->totalNum);
        $this->totalNum += $val;
    }

    public function updateUseNum($val)
    {
        $this->saveColumnStatus(5, $this->useNum);
        $this->useNum += $val;
    }

}